﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Database;

namespace WindowsFormsApplication1
{
    public partial class FormAdminAccess2 : Form
    {

        public ForumService forumService;
        private User man;


        public FormAdminAccess2(string stats,ForumService fs)
        {
            InitializeComponent();
            this.forumService = fs;
            this.textBox1.Text = stats;
            this.textBox1.Enabled = false;
            loadEntry();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.panelManagerInfo.Show();
            this.EntryPanel.Hide();
        }

        private void buttonClose1_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }

        private void buttonClose2_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }

        private void buttonNext1_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(maskedTextBox1.Text) || String.IsNullOrEmpty(maskedTextBox2.Text) || String.IsNullOrEmpty(maskedTextBox3.Text) || String.IsNullOrEmpty(maskedTextBox4.Text) || String.IsNullOrEmpty(maskedTextBox5.Text))
                new FormError("One of the fields is empty!").Show();
            else
            {
                this.man = new User(maskedTextBox3.Text, maskedTextBox1.Text, maskedTextBox2.Text, maskedTextBox4.Text, maskedTextBox5.Text);
                this.panelManagerInfo.Hide();
                this.panelForumInfo.Show();
            }
        }

        private void loadEntry()
        {
            this.panelManagerInfo.Hide();
            this.EntryPanel.Show();
            this.panelForumInfo.Hide();
            this.maskedTextBox1.Clear();
            this.maskedTextBox2.Clear();
            this.maskedTextBox3.Clear();
            this.maskedTextBox4.Clear();
            this.maskedTextBox5.Clear();
            this.man = null;
        }


        private void buttonCancel1_Click(object sender, EventArgs e)
        {
            loadEntry();
        }

        private void buttonCancel2_Click(object sender, EventArgs e)
        {
            loadEntry();
            this.maskedTextBox10.Clear();
        }

        private void buttonNext2_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(maskedTextBox10.Text))
                new FormError("One of the fields is empty!").Show();
            else
            {
                forumService.CreateForum(this.man, maskedTextBox10.Text);
                loadEntry();
                this.maskedTextBox10.Clear();
            }
        }
    }
}
